package main

import "fmt"

func incr() func() int {
	i := 0
	return func() int {
		i = i + 1
		return i
	}
}

func main() {
	func1 := incr()
	var ret1 int
	for i := 1; i < 10; i++ {
		ret1 = func1()
		fmt.Printf("ret1 = %d, func address = %p\n", ret1, &func1)
	}

	fmt.Println("-----------------------------------------")
	func2 := incr()
	for i := 1; i < 10; i++ {
		ret2 := func2()
		fmt.Printf("ret2 = %d, func address = %p\n", ret2, &func2)
	}
}
